preferences.rulerUnits = Units.PIXELS;
formatFolder(Folder('E://ps-video'), '');

function formatFolder(folderObj, baseName) {
  var folderList = folderObj.getFiles();
  var fileIndex = 1;
  for (var i = 0; i < folderList.length; i++) {
    var folderItem = folderList[i];
    if (folderItem instanceof File) {
      var extendName = folderItem.name.substr(-4);
      if (extendName === '.mp4')
        resolveFile(folderItem, baseName, (fileIndex ++) + extendName);
    } else {
      formatFolder(folderItem, baseName + folderItem.name + '/');
    }
  }
}

function resolveFile(fileDoc, baseFolderName, fileName) {
  app.open(fileDoc);
  formatFile(fileDoc, baseFolderName, fileName, 12);
  app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}

function formatFile(fileDoc, baseFolderName, fileName, quality) {
  var doc = app.activeDocument;
  //alert(doc.height + ';' + doc.width);
  var folderPath = 'E://ps-video/' ;
  var newDoc = File(folderPath +'/2.mp4');
  var saveOptions = new JPEGSaveOptions();
  saveOptions.quality = quality
  doc.saveAs(newDoc, PICTResourceSaveOptions, true);
}

function isOverSizeFile(doc) {
  // 1048576 * 3
  return File(doc.toString()).length > 3145728;
}